package com.xinxin.o2o.util;

import com.xinxin.o2o.enums.GlobalCode;
import com.xinxin.o2o.response.Response;

/**
 * @author 史鑫鑫
 * @date 2019-08-13 17:17
 */
public class ResponseUtil {
    public static Response<Object> success(Object data) {
        return new Response<>(200, "success", data);
    }

    public static Response<Object> success() {
        return success(null);
    }

    public static Response error(Integer code, String msg) {
        return new Response(code, msg);
    }

    public static Response error(GlobalCode globalCode) {
        return new Response(globalCode.getCode(), globalCode.getMsg());
    }

    public static Response error(GlobalCode globalCode, String msg) {
        return new Response(globalCode.getCode(), globalCode.getMsg() + " : " + msg);
    }
}
